package com.credithc.customers.base.service;

import com.credithc.customers.base.constants.TableEnum;
import com.credithc.customers.base.po.*;
import com.credithc.customers.base.ro.*;
import com.credithc.customers.base.vo.CustOauthTokenVo;
import com.credithc.customers.base.vo.LoginFlowVo;

import java.security.GeneralSecurityException;
import java.sql.Timestamp;
import java.util.List;
import java.util.Map;

/**
 * @author zhukai
 * @date 2018/12/20 13:47
 */
public interface ICommonService {

    /**
     * 校验请求流水号是否重复统一入口
     *
     * @param requestNo 请求流水号
     * @param tableEnum 需要查询的表名
     */
    void checkRepeatRequestNo(String requestNo, TableEnum tableEnum);

    /**
     * 根据用户号获取客户
     *
     * @param preCustomerNo 用户号
     * @return po
     */
    PreCustomerInfoPo getExistPreCustomer(String preCustomerNo);


    /**
     * 根据证件类型以及证件号判断用户是否存在
     *
     * @param contactType 联系方式类型
     * @param contactInfo 联系方式
     * @return 用户po
     */
    PreCustomerInfoPo getExistPreCustomer(String contactType, String contactInfo);

    /**
     * 插入客户身份信息
     *
     * @param ro         ro
     * @param customerNo 客户号
     * @param subSystemSign    请求实体
     * @param remark     备注
     * @return int
     */
    void insertCustomerIdInfo(CustomerIdInfoRo ro, String customerNo, String subSystemSign, String remark, boolean isPre);


    /**
     * 新增手机号流水
     *
     * @param po po
     */
    void insertContactFlow(CustomerContactFlowPo po);

    /**
     * 根据客户号获取客户
     *
     * @param customerNo 客户号
     * @return 客户
     */
    CustomerInfoPo getExistCustomer(String customerNo);

    /**
     * @param systemSign
     * @param subSystemSign
     * @description: 获取当前系统对应证件信息
     * @author: denghx
     * @param: customerNo
     * @return: com.credithc.customers.base.po.CustomerIdInfoPo
     */
    CustomerIdInfoPo getExistCustomer(String customerNo, String systemSign, String subSystemSign);

    /**
     * @param systemSign
     * @param subSystemSign
     * @description: 查询当前客户号所有证件信息
     * @author: denghx
     * @date: 2018/12/21 17:30
     * @param: customerNo
     * @return: java.util.List<com.credithc.customers.base.po.CustomerIdInfoPo>
     */
    List<CustomerIdInfoPo> getAllCustomer(String customerNo, String systemSign, String subSystemSign);


    CustomerIdInfoPo getExistCustomerInfo(String customerName, String idCardType, String idCardNo);

    CompanyIdInfoPo getCompanyInfo(String unifiedCode, String licenseNo, String orgNo, String taxNo);


    /**
     * 获取已经存在的客户联系方式
     *
     * @param systemSign    系统标识
     * @param subSystemSign 子系统标识
     * @param contactType   联系方式类型
     * @param contactInfo   联系方式
     * @return 客户联系方式po
     */
    CustomerContactInfoPo getExistCustomerContact(String systemSign, String subSystemSign, String contactType, String contactInfo, String customerNo);

    CustomerContactInfoPo getExistCustomerContact(String systemSign, String subSystemSign, String customerNo);

    /**
     * 插入客户联系信息
     *
     * @param ro         ro
     * @param customerNo 客户号
     * @param request    请求实体
     * @param remark     备注
     * @return int
     */
    void insertCustomerContactInfo(ContactRo ro, String customerNo, BaseRequest request, String remark);

    /**
     * 校验变更联系方式的入参，修改联系人
     *
     * @param request    request
     * @param customerNo 客户号
     * @param isPre      是不是用户
     */
    void checkContactModifyParam(BaseRequest<CustomerContactModifyRo> request, String customerNo, boolean isPre);

    boolean verifySign(String data, String signature, SystemInfoPo system) throws GeneralSecurityException;

    /**
     * @param systemSign
     * @param subSystemSign
     * @description: 判断对应系统用户号是否存在
     * @author: denghx
     * @date: 2018/12/6 22:23
     * @param: preCustomerNo
     * @return: boolean
     */
    CustomerExtendPo getExistPreCustomerExtend(String preCustomerNo, String systemSign, String subSystemSign);

    CustomerExtendPo getExistCustomerExtend(String preCustomerNo, String customerNo, String systemSign, String subSystemSign);

    List<CustomerExtendPo> getExistPreCustomerExtendList(String preCustomerNo, String systemSign, String subSystemSign);

    List<CustomerExtendPo> getExistAssociatedPreCustomerExtendList(String associatedCustomerNo, String systemSign, String subSystemSign);


    /**
     * @param
     * @description: 发送通知
     * @author: denghx
     * @date: 2018/12/22 10:34
     * @param: receiver
     * @return: java.lang.String
     */
    String sendHttpMsg(String receiver, String id, String customerNo, String customerName, String idCardType, String idCardNo, String oldCustomerName, String oldIdCardType, String oldIdCardNo);

    /**
     * @description: 邮件发送
     * @date: 2019/1/22 10:43
     * @param: ro
     * @return: java.lang.String
     */
    void sendEmail(EmailSendRo ro);

    /**
     * @param id
     * @param customerNo
     * @param customerName
     * @param idCardType
     * @param idCardNo
     * @param mergeCustomerNo
     * @description: 客户合并通知
     * @param: receiver
     * @return: java.lang.String
     */

    String sendMergeNotice(String receiver, String id, String customerNo, String customerName, String idCardType, String idCardNo, String mergeCustomerNo);


    /**
     * 修改用户关系
     *
     * @param systemSign
     * @param subSystemSign
     * @param oldPreCustomerNo
     * @param newPreCustomerNo
     */
    void updateRelation(String systemSign, String subSystemSign, String oldPreCustomerNo, String newPreCustomerNo);


    /**
     * 修改用户产品记录
     *
     * @param systemSign
     * @param subSystemSign
     * @param oldPreCustomerNo
     * @param newPreCustomerNo
     */
    void updateCustomerProduct(String systemSign, String subSystemSign, String oldPreCustomerNo, String newPreCustomerNo);

    /**
     * 获取产品信息
     *
     * @param tableKey
     * @param systemSign
     * @param subSystemSign
     * @return
     */
    ProductInfoPo getProductInfo(String tableKey, String systemSign, String subSystemSign);

    /**
     * 获取客户产品信息
     *
     * @param userSourceId
     * @param productNo
     * @return
     */
    CustomerProductInfoPo getCustomerProduct(String userSourceId, String productNo, String tableName, String tableKey);

    /**
     * 获取客户账户信息
     *
     * @param userSourceId
     * @param accountNo
     * @param systemSign
     * @param subSystemSign
     * @return
     */
    CustomerAccountPo getCustomerAccount(String userSourceId, String accountNo, String systemSign, String subSystemSign, Integer status);

    CustomerAccountPo getCustomerAccount(String userSourceId, String accountNo, String systemSign, String subSystemSign);

    /**
     * 获取业务系统与一账通系统字典对照表
     *
     * @param mapperType
     * @param code
     * @param systemSign
     * @param subSystemSign
     * @return
     */
    DictMapperPo getDictMapper(String mapperType, String code, String systemSign, String subSystemSign);

    /**
     * 获取系统
     *
     * @param systemSign
     * @param subSystemSign
     * @return
     */
    SystemInfoPo getSystemInfo(String systemSign, String subSystemSign);

    /**
     * 依据产品号获取对应系统
     *
     * @param productCode
     * @return
     */
    SystemInfoPo getSystemInfo(String productCode);

    /**
     * 获取角色来源
     *
     * @param systemSign
     * @param subSystemSign
     * @return
     */
    String getRoleSource(String systemSign, String subSystemSign);

    /**
     * 获取关系来源
     *
     * @param systemSign
     * @param subSystemSign
     * @return
     */
    String getRelationSource(String systemSign, String subSystemSign);

    /**
     * 获取客户角色
     *
     * @param userSourceId
     * @param role
     * @param systemSign
     * @param subSystemSign
     * @return
     */
    CustomerRolePo getCustomerRole(String userSourceId, String role, String systemSign, String subSystemSign);

    /**
     * 获取客户角色来源
     *
     * @param userSourceId
     * @param systemSign
     * @param subSystemSign
     * @return
     */
    String getCustomerRoleSource(String userSourceId, String systemSign, String subSystemSign);

    int updateCustomerNo4SyncData(String userId, String customerNo, String preCustomerNo, String systemSign, String subSystemSign);

    /**
     * @description: 依据客户号获取所有对应系统
     * @author: denghx
     * @date: 2019/11/1 16:06
     * @param: customerNo
     * @return: java.util.List<com.credithc.customers.base.po.CustomerManageInfoPo>
     */
    List<CustomerManageInfoPo> getCustomerManageInfo(String customerNo);

    void insertPreCustomerPass(String preCustomerNo, String systemSign, String subSystemSign, String password, String mobile);

    void insertCustUnifyRegisterFlow(String phone, String systemSign, String subSystemSign, String requestNo, Integer statusSuccess, String errorMsg, String password);


    /**
     * @description: 助贷统一登录公用方法
     */
    CustomerExtendPo getCustomerUnifyInfo(String preCustomerNo, String customerNo, String systemSign, String subSystemSign);

    void insertCustUnifyLoginFlow(String phone, String systemSign, String subSystemSign, String requestNo, Integer statusSuccess, String errorMsg, String password, String smsCode, String loginCode);

    List<LoginFlowVo> getCustomerUnifyLoginFlowList(String subSystemSign, String phone, Integer status, String password, List<String> time);

    /**
     * @description: 短信发送验证码
     * @author: denghx
     * @date: 2020/1/16 16:57
     * @param: ro
     * @return: java.util.Map<java.lang.String               ,               java.lang.Object>
     */
    void sendSms(String mobile, String content, String systemSign, String subSystemSign, String type);

    /**
     * @param systemSign
     * @param subSystemSign
     * @param requestNo
     * @param status
     * @param errorMsg
     * @param smsCode
     * @description:
     * @author: denghx
     * @date: 2020/1/16 23:58
     * @param: phone
     * @return: void
     */
    void insertCustUnifySmsFlow(String phone, String systemSign, String subSystemSign, String requestNo, Integer status, String errorMsg, String smsCode, String ip);

    void updateCustUnifySmsFlow(Timestamp unlockTime, Integer id);

    void insertCustUnifyUpdateFlow(String requestParam, String systemSign, String subSystemSign, String requestNo, Integer statusSuccess, String errorMsg);

    // 助贷统一登录接口开始
    CustOauthTokenPo getOauthCode(String code);

    CustOauthChannelPo getOauthChannel(String preCustomerNo, String subSystemId, String channelId);

    CustOauthTokenPo getOauthCode(String preCustomerNo, String subSystemId);

    void updateCustOauthToken(String preCustomerNo, String subSystemId, String loginCode, Integer status, Integer regesterStatus, String creditSystem);

    void insertCustOauthToken(String preCustomerNo, String systemId, String subSystemId, String loginCode, Integer status, Integer regesterStatus, String creditSystem);

    void insertCustOauthChannel(String preCustomerNo, String systemId, String subSystemId, String channelId);

    CustOauthTokenVo getOauthTokenInfo(String accessToken, String subSystemId);

    void insertCustomerExtend(String systemSign, String subSystemSign, String remark, String preCustomerNo);

    void verifySignature(String mainSystemId, String requestTimestamp, String code, String signature);

    void verifyH5(String systemSign, String subSystemSign, String requestTimestamp, String signature);

    Map<String, String> custIdentity(String cid, String name);

    CustomerIdInfoPo getCustomerIdInfo(String customerNo);

    CompanyIdInfoPo getCompanyIdInfo(String customerNo);

    void insertCustCancelFlow(String phone, String systemSign, String subSystemSign, String requestNo, Integer status, String errorMsg, String preCustomerNo, String customerNo);

    void insertCustUntieFlow(String systemSign, String subSystemSign, String requestNo, Integer status, String errorMsg, String preCustomerNo, String customerNo, String name, String idType, String idNo);

    void updateCode(String id, String customerNo, String loginCode);

    CustOauthTokenPo getOauthToken(String accessToken, String subSystemId);

    Map<String, String> getOnlineToken(String systemSign, String subSystemSign, String merchantNo, String courseId, String requestNo, String phone, String preCustomerNo, String riskNo, String money);

    CustomerExtendCreditPo getCreditInfo(String phone, String channelNo, String subSystemSign);

    void insertCustExtendCredit(String systemSign, String subSystemSign, String channelNo, String preCustomerNo, String ext1, String ext2, String ext3, String phone);

    CustomerExtendPo getRegisterSystem(String preCustomerNo, String systemSign);

    CustOauthTokenPo getOauthCodeInfo(String code, String subSystemSign);

    CustomerManageInfoPo getCustomerManageInfo(String customerNo, String subSystemSign);

    void updateTokenByPre(String newPreCustomerNo, String subSystemSign, String oldPreCustomerNo);

    void updateChannelByPre(String newPreCustomerNo, String subSystemSign, String oldPreCustomerNo);

    void updateCustPreInfo(String id, String phone);

    void insertCustPreInfo(String preCustomerNo, String contactInfo);

    void insertCompanyModifyFlow(UnifyModifyBusinessRo ro,String systemSign,String subSystemSign,String modifyMsg);

    void insertCustOauthLoginFlow(String requestNo,String systemSign, String subSystemSign, String loginCode, String preCustomerNo, Integer status);

    void insertCompanyIdInfo(CompanyIdInfoRo companyIdInfoRo, String customerNo, String subSystemSign);

    void updateCustOauthLoginFlow(String systemSign, String subSystemSign, String loginCode, String preCustomerNo, Integer status);

    void updateCustExtendById(String id, Integer status);

    CustInvitationCodePo getInvitationCode(String preCustomerNo, String systemSign, String subSystemSign);

    CustInvitationRelationPo getInvitationRelation(String preCustomerNo, String systemSign, String subSystemSign);

    String handleInvitationCode(BaseRequest<CustomerUnifyLoginRo> request,String preCustomerNo);

    void insertInvitationCode(String preCustomerNo,String phone,String invitationCode, String systemSign, String subSystemSign);

    void deleteCustIdInfoById(String id);

    void deleteCustManageInfo(String customerNo, String subSystemSign);

    void updateChannelById(String id, Integer status, String remark);

    void updateCustExtendByAuth(String preCustomerNo, String systemSign, String subSystemSign, Integer status);

    void updateChannelByCancel(String preCustomerNo, String systemSign, String subSystemSign, Integer status, String remark);

    void updateInvitationCode(String preCustomerNo, String systemSign, String subSystemSign, Integer status, String remark);

    void updateInvitationRelation(String preCustomerNo, String systemSign, String subSystemSign, Integer status, String remark);

    PreCustomerPasswdPo getPasswd(String phone,String preCustomerNo, String systemSign, String subSystemSign, Integer status);

    void insertPasswd(String phone, String preCustomerNo, String systemSign, String subSystemSign,String passwd, Integer status);

    void updatePasswdById(Integer id, String password, String remark);

    void updatePasswdByCancel(String phone, String systemSign, String subSystemSign, Integer status, String remark);

    void updatePasswdByModify(String phone,String newPhone,String newPreCustomerNo, String systemSign, String subSystemSign,String remark);

    void insertCustSmsPwdFlow(String phone, String systemSign, String subSystemSign, String requestNo, Integer status, String errorMsg, String smsCode, String ip, Integer type);

    void updateCustSmsPwdFlow(Timestamp unlockTime, Integer id);

}
